package com.sunda.spmsorder.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunda.spmsorder.entity.MaterialSrmLongContract;
import com.sunda.spmsorder.mapper.MaterialSrmLongContractMapper;
import com.sunda.spmsorder.service.IMaterialSrmLongContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * SRM长协表 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-01-25
 */
@Service
public class MaterialSrmLongContractServiceImpl extends ServiceImpl<MaterialSrmLongContractMapper, MaterialSrmLongContract> implements IMaterialSrmLongContractService {

    @Autowired
    MaterialSrmLongContractMapper materialSrmLongContractMapper;

    @Override
    public List<Map<String, Object>> getByMaterialNoList(String materialNoList) {
        try {
            List<String> list = new ArrayList<>();
            if (materialNoList.trim().length() > 0){
                String[] array = materialNoList.trim().split(",");
                for (int i = 0; i < array.length; i++){
                    list.add(array[i]);
                }
            }
            if (list.size() == 0){
                return null;
            }
            return materialSrmLongContractMapper.getByMaterialNoList(list);
        }catch (Exception e){
            return null;
        }
    }

    @Override
    public List<Map<String, Object>> getByMaterialNo(String materialNo) {
        try {
            return materialSrmLongContractMapper.getByMaterialNo(materialNo);
        }catch (Exception e){
            return null;
        }
    }
}
